﻿@model IQueryable<viBook.Models.Activity>
@{
    ViewBag.Title = "User activities";
    Layout = "~/Views/Shared/_UserLayout.cshtml";
    var locality = (String.IsNullOrEmpty(ViewBag.Location)) ? "Secret" : ViewBag.Location;
}
<div class="full">
    <div class="profile vcard profile-freeagent group">
        <img alt="@(ViewBag.AvatarUrl)'s avatar" class="photo" src="@ViewBag.AvatarUrl" />
        <h1>
            <span class="fn edit">@ViewBag.DisplayName</span>
        </h1>
        <ul class="profile-details">
            <li><span class="locality">@locality</span></li>
        </ul>
        @if (ViewBag.IsOwner)
        {
            <a href="@Url.Action("details", "account")" class="action edit-account"><span>Edit Your
            Account</span></a>
        }
        
    </div>
</div>
<div id="main">
    <ul class="tabs">
    @if (ViewBag.IsOwner)
    {
        <li><a href="@Url.Action("Index", "Account")">Uploaded Books</a>
        </li>
        <li class="active"><a href="@Url.Action("Activities", "Account")">Recent activities</a>
        </li>
    }
    @if (!ViewBag.IsOwner)
    {
        <li><a href="@Url.Action("Index", "Account", new {id = Model.FirstOrDefault().UserId})">Uploaded Books</a>
        </li>
        <li class="active"><a href="@Url.Action("Activities", "Account", new { id = Model.FirstOrDefault().UserId })">Recent activities</a>
        </li>
    }
    </ul>
    <ol class="activity" >  
        <div data-bind='template: { name: "activity-template", foreach: activitiesCollection }' id="activities-list">
        </div>    
    </ol>
    @*Pager*@
    <div class="page">
        <div class="pagination">
            <a class="next_page" rel="next" id="prev" data-bind="visible: isShowPrevBtn, click: fetchPreviousActivitiesPage">Previous</a>
             (Page <span data-bind="text: viewmodel.activitiesPageNo()"></span> of 
            <span data-bind="text: viewmodel.totalActivitiesPages()"></span>)
            <a class="next_page" rel="next" id="next" data-bind="visible: isShowNextBtn, click: fetchNextActivitiesPage">Next</a>
        </div>
    </div>
    
</div>

@Html.Partial("ActivitiesJS")
